package com.net.example;

import java.net.InetAddress;
import java.net.UnknownHostException;
import java.io.*;

public class IPScan2 {
	static public void main(String[] args) {
		String ip;
		try {
			// 通过主机名称得到IP地址
			// InetAddress address = InetAddress.getByName(args[0]);
			// System.out.println(args[0]+": "+address.getHostAddress());

			// 通过IP得到主机名称
			String ips = "192.168.0.";
			
			InetAddress addip;
			for (int i = 1; i < 255; i++) {
				ip = ips + i;
				addip = InetAddress.getByName(ip);
				System.out.println(ip + ": " + addip.getHostName());

			}

		} catch (UnknownHostException uhe) {

		}
	}
}